package com.gupao.javavip.concurrent.service;

import com.gupao.javavip.concurrent.lock.ConfigLoader;

import java.util.concurrent.TimeUnit;

public class ExportJob {
    public void execute() {
        Dao dao = new Dao();
        Export export = new Export();
        export.export(dao.queryData());
    }

    public static void main(String[] args) {
        ConfigLoader.startConfigMonitor();

        for (int j = 0; j < 5; j++) {
            Thread thread = new Thread(() -> {
                ExportJob job = new ExportJob();

                for (int i = 0; i < 10; i++) {
                    job.execute();

                    try {
                        TimeUnit.SECONDS.sleep(5L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });

            thread.start();
        }
    }
}
